package com.mxw;

import com.lmax.disruptor.BlockingWaitStrategy;
import com.lmax.disruptor.dsl.ProducerType;
import com.mxw.client.MessageConsumerImpl4Client;
import com.mxw.client.NettyClient;
import com.mxw.disruptor.MessageConsumer;
import com.mxw.disruptor.RingBufferWorkerPoolFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(ClientApplication.class, args);
        MessageConsumer[] conusmers = new MessageConsumer[4];

        for(int i =0; i < conusmers.length; i++) {
            MessageConsumer messageConsumer = new
                    MessageConsumerImpl4Client("code:clientId:" + i);
            conusmers[i] = messageConsumer;
        }
        RingBufferWorkerPoolFactory.getInstance().initAndStart(ProducerType.MULTI,
                1024*1024,
                new BlockingWaitStrategy(),
                conusmers);

        NettyClient nettyClient = new NettyClient();
        nettyClient.sendData();
    }
}